<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>

<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<base href="<%=basePath%>">
<!-- 下拉框 -->
<link rel="stylesheet" href="static/ace/css/chosen.css" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta charset="utf-8" />
<title>船公司箱主代码管理</title>
<meta name="description" content="" />
<meta name="viewport"
	content="width=device-width, initial-scale=1.0, maximum-scale=1.0" />

<link rel="stylesheet" href="static/ace/css/bootstrap.css" />
<link rel="stylesheet" href="static/ace/css/font-awesome.css" />

<!-- text fonts -->
<link rel="stylesheet" href="static/ace/css/ace-fonts.css" />
<!-- ace styles -->
<link rel="stylesheet" href="static/ace/css/ace.css"
	class="ace-main-stylesheet" id="main-ace-style" />
<script type="text/javascript" src="static/js/jquery-1.7.2.js" /></script>
<script type="text/javascript">
			$(top.hangge());
		</script>
<!--提示框-->
<script type="text/javascript" src="static/js/jquery.tips.js"></script>
</head>
<body class="no-skin">
	<div class="main-container" id="main-container">
		<div class="main-content">
			<div class="main-content-inner">
				<div class="page-content">
					<div class="row">
						<div class="col-xs-12">
							<form method="post" id="shipownerForm">
								<fieldset>
									<table style="margin-top: 5px;"
										class="table table-striped table-bordered table-hover">
										<tr>
											<td
												style="width:80px; text-align: right; padding-top: 13px;">快速检索码:</td>

											<td><input type="text" name="INDEX_CODE" id="INDEX_CODE"
												 maxlength="32" style="width: 98%;" /></td>

											<td
												style="width:80px; text-align: right; padding-top: 13px;">是否可用:</td>
											<td><select style="width: 195px;" name="ENABLE">
													<option value="">全部</option>
													<option value="1">是</option>
													<option value="0">否</option>
											</select></td>
											<td
												style="width:80px; text-align: right; padding-top: 13px;">箱主代码:</td>
											<td><input type="text" name="OWNER_CODE" id="OWNER_CODE"
												maxlength="32" style="width: 98%;" /></td>
											<td
												style="width:80px; text-align: right; padding-top: 13px;">英文名称:</td>
											<td><input type="text" name="ENAME" id="ENAME"
												maxlength="32" style="width: 98%;" /></td>
											<td
												style="width:80px; text-align: right; padding-top: 13px;">箱主名称:</td>
											<td><input type="text" name="OWNER_NAME" id="OWNER_NAME"
												maxlength="32" style="width: 98%;" /></td>
											<td
												style="width:80px; text-align: right; padding-top: 13px;">简称:</td>
											<td><input type="text" name="SHORT_NAME" id="SHORT_NAME"
												maxlength="32" style="width: 98%;" /></td>
										</tr>
										<tr>
											<td
												style="width:81px; text-align: right; padding-top: 13px;">提单要求:</td>
											<td><textarea id="BILL_REQUIREMENT"
													name="BILL_REQUIREMENT" style="width:98%;"></textarea></td>
											<td
												style="width:79px; text-align: right; padding-top: 13px;">海船公司订舱注意事项:</td>
											<td><textarea id="SEA_BOOKING_OPTION"
													name="SEA_BOOKING_OPTION" style="width: 98%;"></textarea></td>
											<td
												style="width: 79px; text-align: right; padding-top: 13px;">海船公司收付备注:</td>
											<td><textarea id="OCE_COLLECT_REMARK"
													name="OCE_COLLECT_REMARK" style="width: 98%;"></textarea></td>
											<td style="text-align: left;" colspan="10"><a
												class="btn btn-xs btn-success"> <i
													class="ace-icon fa fa-pencil-square-o bigger-120"
													onclick="add();">添加</i>
											</a></td>
										</tr>
										<tr>

										</tr>
									</table>
								</fieldset>
							</form>
							<form  method="post" id="shipoener">
								<fieldset>
									<table style="margin-top: 5px;"
										class="table table-striped table-bordered table-hover">
										<tr>
											<td
												style="width: 79px; text-align: right; padding-top: 13px;">箱主代码：</td>
											<td><input type="text" id="start" name="OWNER_CODE"
												value="${pd.OWNER_CODE }" maxlength="32" style="width: 98%;" /></td>
											<td
												style="width: 79px; text-align: right; padding-top: 13px;">英文名称：</td>
											<td><input type="text" id="end" name="ENAME"
												value="${pd.ENAME }" maxlength="32" style="width: 98%;" /></td>
											<td
												style="width: 79px; text-align: right; padding-top: 13px;">箱主名称：</td>
											<td><input type="text" id="start" name="OWNER_NAME"
												value="${pd.OWNER_NAME }" maxlength="32" style="width: 98%;" /></td>
											<td
												style="width: 79px; text-align: right; padding-top: 13px;">箱主简称：</td>
											<td><input type="text" id="end" name="SHORT_NAME"
												value="${pd.SHORT_NAME }" maxlength="32" style="width: 98%;" /></td>
											<td
												style="width: 79px; text-align: right; padding-top: 13px;">检索码：</td>
											<td><input type="text" id="end" name="INDEX_CODE"
												value="${pd.INDEX_CODE }" maxlength="32" style="width: 98%;" /></td>
											<td style="text-align: left;" colspan="10"><a
												class="btn btn-xs btn-success"> <i
													class="ace-icon fa fa-pencil-square-o bigger-120"
													onclick="serch();">查询</i>
											</a></td>
										</tr>
									</table>
								</fieldset>
							</form>
<div style="float:left; padding: 10px"><input type="button" value="批量删除"  onclick="shan()" id="shan"/></div>
<!-- <div style="float:left; padding: 10px"><input id="fileId2" type="file" multiple="multiple" name="file"  /></div> -->
<!-- <div style="float:left; padding: 10px;margin-right:10px" ><input type="button"  value="导入" style="margin:left"/></div> -->
		

					<table id="simple-table"
								class="table table-striped table-bordered table-hover"
								style="margin-top: 5px;">
								<thead>
									<tr>
										<th class="center" style="width: 30px;"><label
											class="pos-rel"><input type="checkbox" class="ace"
												id="selectAll" /><span class="lbl"></span></label></th>
										<th class="center">箱主代码</th>
										<th class="center">英文名称</th>
										<th class="center">箱主名称</th>
										<th class="center">简称</th>
										<th class="center">是否可用</th>
										<th class="center">检索码</th>
										<th class="center">海船公司收付备注</th>
										<th class="center">海船公司订舱注意事项</th>
										<th class="center">简单要求</th>
										<th class="center">修改</th>
										<th class="center">删除</th>
									</tr>
								</thead>
								<c:forEach items="${list}" var="ship">
								   <tr>

										<td class="center" style="width: 30px;"><label
											class="pos-rel"><input type="checkbox" class="s1" name="s1"
												value="${ship.ID}" /><span class="lbl"></span></label></td>
										<td class="center">${ship.OWNER_CODE}</td>
										<td class='center'>${ship.ENAME}</td>
										<td class="center">${ship.OWNER_NAME}</td>
										<td class="center">${ship.SHORT_NAME}</td>
										<td class="center"><c:if test="${ship.ENABLE ==1}">
        		                                              是
        </c:if> <c:if test="${ship.ENABLE ==0}">
        		                                               否
        </c:if></td>
										
										<td class="center">${ship.INDEX_CODE}</td>
										<td class="center">${ship.OCE_COLLECT_REMARK}</td>
										<td class="center">${ship.SEA_BOOKING_OPTION}</td>
										<td class="center">${ship.BILL_REQUIREMENT}</td>
										<td class="center">
											<div class="hidden-sm hidden-xs btn-group">
												<a class="btn btn-xs btn-success"
													onclick="edit('${ship.ID}');"> <i
													class="ace-icon fa fa-pencil-square-o bigger-120">修改</i>
												</a>
											</div>
										</td>
										<td class="center">
											<div class="hidden-sm hidden-xs btn-group">
												<a class="btn btn-xs btn-success"
													onclick="delet('${ship.ID}');"> <i
													class="ace-icon fa fa-trash-o bigger-120">删除</i>
												</a>
											</div>
										</td>
                                     </tr>
									</c:forEach>
								
							</table>



						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
</body>
<script type="text/javascript">
$(document).ready(function(){
	$("#selectAll").click(function(){
		if(this.checked){
			$(".s1:checkbox,selectAll").prop("checked", true);
			
		}else{
			$(".s1:checkbox,selectAll").prop("checked", false);
			
		}
	
	})
	$(".s1").click(function() {
			var obj = $(".s1");
			var flag = true;
			obj.each(function() {
				if (!$(this).is(":checked")) {
					flag = false;
					return false;
				}
			});
			if (flag == true) {
				$("#selectAll").prop("checked", true);
			} else {
				$("#selectAll").prop("checked", false);
			}
	
	
})
$("#shan").click(function(){

	     
	var arr=document.getElementsByName("s1");
	
	for(i=0;i<arr.length;i++){
	if(arr[i].checked){
	var a = arr[i].value;
	
	

	}

	}

	
})



})
</script>
<script type="text/javascript">
//新增
function add(){
	if($("#INDEX_CODE").val()==""){
		$("#INDEX_CODE").tips({
			side:3,
            msg:'请填写快速检索码',
            bg:'#AE81FF',
            time:2
        });
		$("#INDEX_CODE").focus();
		$("#INDEX_CODE").val('');
		$("#INDEX_CODE").css("background-color","white");
		return false;
	}
	if($("#ENABLE").val()==""){
		$("#ENABLE").tips({
			side:3,
            msg:'请填写是否可用',
            bg:'#AE81FF',
            time:2
        });
		$("#ENABLE").focus();
		$("#ENABLE").val('');
		$("#ENABLE").css("background-color","white");
		return false;
	}
	if($("#OWNER_CODE").val()==""){
		$("#OWNER_CODE").tips({
			side:3,
            msg:'请填写箱主代码',
            bg:'#AE81FF',
            time:2
        });
		$("#OWNER_CODE").focus();
		$("#OWNER_CODE").val('');
		$("#OWNER_CODE").css("background-color","white");
		return false;
	}
	if($("#ENAME").val()==""){
		$("#ENAME").tips({
			side:3,
            msg:'请填写英文名',
            bg:'#AE81FF',
            time:2
        });
		$("#ENAME").focus();
		$("#ENAME").val('');
		$("#ENAME").css("background-color","white");
		return false;
	}
	
	if($("#OWNER_NAME").val()==""){
		$("#OWNER_NAME").tips({
			side:3,
            msg:'请填写箱主名称',
            bg:'#AE81FF',
            time:2
        });
		$("#OWNER_NAME").focus();
		$("#OWNER_NAME").val('');
		$("#OWNER_NAME").css("background-color","white");
		return false;
	}
	if($("#SHORT_NAME").val()==""){
		$("#SHORT_NAME").tips({
			side:3,
            msg:'请填写简称',
            bg:'#AE81FF',
            time:2
        });
		$("#SHORT_NAME").focus();
		$("#SHORT_NAME").val('');
		$("#SHORT_NAME").css("background-color","white");
		return false;
	}
	
	 $.ajax({
         type: "POST",
         url: '<%=basePath%>ship/addship',
         data: $("#shipownerForm").serialize(),
         dataType: 'json',
         cache: false,
         success: function (data) {
        	 alert("保存成功")
        	 window.location.reload();
        	 
         }
     });
}

   //查詢
	function serch() {
		top.jzts();
		$("#shipoener").submit();
	}
	
   //修改
   function edit(ID){
	   top.jzts();
	    var diag = new top.Dialog();
	    diag.Drag = true;
	    diag.Title = "编辑";
	    diag.URL = '<%=basePath%>ship/editship?ID=' + ID;
	    diag.Width = 600;
	    diag.Height = 415;
	    diag.CancelEvent = function () { //关闭事件
	    	diag.close();
	  
	    	window.location.reload();	
	    };
	    diag.show();
	}
	   
 //删除
   function delet(ID){
  	
  	if (confirm("确认要删除本条信息！")){
  		$.ajax({
  			type:"post",
  			url:'<%=basePath%>ship/deleteU?ID='+ID,
  			success:function(){
  				window.location.reload();
  			}
  			
  		})
  		return false;
  		}
  	
  	
  	
  }   
 //全删
function shan(){
alert("000")
	var trList = [];
var $simpleTabletr = $("#simple-table tbody tr");
var list = {}
for(var i=0,len=$simpleTabletr.length;i<len;i++){
var objTr = $simpleTabletr[i];
var flag = $(objTr).find("td").first().find("label").find(".s1")[0].checked;

if(flag){
trList.push(objTr);
}
}
//传到后台的data json格式
var data = [];
for(var i=0,size=trList.length;i<size;i++){
var $tds = $(trList[i]).find("td");
//取id
var id = $($tds[0]).find("label").find("input[name='s1']")[0].value;
var item = {};
item.ID = id.trim();

data.push(item)
}
var dataStr = JSON.stringify(data);
if (confirm("确认要删除选中的信息！")){
$.ajax({
type: "POST",
url: '<%=basePath%>ship/deleteInfo',
data: {dataJsonStr:dataStr},
cache: false,
success:function (data) {
	 window.location.reload();
	 
}
   });

return false;
}

}
	
</script>
</html>